package com.ruoyi.project.system.data.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.data.domain.ParaWarnControlData;
import com.ruoyi.project.system.data.service.IParaWarnControlDataService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 业务预警关于反洗钱参数Controller
 *
 * @author ruoyi
 * @date 2020-03-12
 */
@Controller
@RequestMapping("/system/data")
public class ParaWarnControlDataController extends BaseController
{
    private String prefix = "system/data";

    @Autowired
    private IParaWarnControlDataService paraWarnControlDataService;

    @RequiresPermissions("system:data:view")
    @GetMapping()
    public String data()
    {
        return prefix + "/data";
    }

    /**
     * 查询业务预警关于反洗钱参数列表
     */
    @RequiresPermissions("system:data:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ParaWarnControlData paraWarnControlData)
    {
        startPage();
        List<ParaWarnControlData> list = paraWarnControlDataService.selectParaWarnControlDataList(paraWarnControlData);
        return getDataTable(list);
    }

    /**
     * 导出业务预警关于反洗钱参数列表
     */
    @RequiresPermissions("system:data:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ParaWarnControlData paraWarnControlData)
    {
        List<ParaWarnControlData> list = paraWarnControlDataService.selectParaWarnControlDataList(paraWarnControlData);
        ExcelUtil<ParaWarnControlData> util = new ExcelUtil<ParaWarnControlData>(ParaWarnControlData.class);
        return util.exportExcel(list, "data");
    }

    /**
     * 新增业务预警关于反洗钱参数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存业务预警关于反洗钱参数
     */
    @RequiresPermissions("system:data:add")
    @Log(title = "业务预警关于反洗钱参数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ParaWarnControlData paraWarnControlData)
    {
        return toAjax(paraWarnControlDataService.insertParaWarnControlData(paraWarnControlData));
    }

    /**
     * 修改业务预警关于反洗钱参数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ParaWarnControlData paraWarnControlData = paraWarnControlDataService.selectParaWarnControlDataById(id);
        mmap.put("paraWarnControlData", paraWarnControlData);
        return prefix + "/edit";
    }

    /**
     * 修改保存业务预警关于反洗钱参数
     */
    @RequiresPermissions("system:data:edit")
    @Log(title = "业务预警关于反洗钱参数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ParaWarnControlData paraWarnControlData)
    {
        return toAjax(paraWarnControlDataService.updateParaWarnControlData(paraWarnControlData));
    }

    /**
     * 删除业务预警关于反洗钱参数
     */
    @RequiresPermissions("system:data:remove")
    @Log(title = "业务预警关于反洗钱参数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paraWarnControlDataService.deleteParaWarnControlDataByIds(ids));
    }
}
